# 创建下载目录
$assetsPath = "assets"
$cssPath = "$assetsPath\css"
$jsPath = "$assetsPath\js"
$fontsPath = "$assetsPath\fonts"
$imgPath = "$assetsPath\img"

# 创建目录
New-Item -ItemType Directory -Force -Path $cssPath
New-Item -ItemType Directory -Force -Path $jsPath
New-Item -ItemType Directory -Force -Path $fontsPath
New-Item -ItemType Directory -Force -Path $imgPath

# 下载CSS文件
$cssFiles = @{
    "adminlte.min.css" = "https://cdn.bootcdn.net/ajax/libs/admin-lte/3.2.0/css/adminlte.min.css"
    "select2.min.css" = "https://cdn.bootcdn.net/ajax/libs/select2/4.1.0-rc.0/css/select2.min.css"
    "select2-bootstrap4.min.css" = "https://cdn.jsdelivr.net/npm/select2-bootstrap4-theme@1.0.0/dist/select2-bootstrap4.min.css"
    "dataTables.bootstrap4.min.css" = "https://cdn.jsdelivr.net/npm/datatables.net-bs4@1.11.5/css/dataTables.bootstrap4.min.css"
    "daterangepicker.css" = "https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.css"
    "all.min.css" = "https://cdn.bootcdn.net/ajax/libs/font-awesome/5.15.4/css/all.min.css"
}

# 下载JS文件
$jsFiles = @{
    "jquery.min.js" = "https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js"
    "bootstrap.bundle.min.js" = "https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/4.6.0/js/bootstrap.bundle.min.js"
    "adminlte.min.js" = "https://cdn.bootcdn.net/ajax/libs/admin-lte/3.2.0/js/adminlte.min.js"
    "select2.min.js" = "https://cdn.bootcdn.net/ajax/libs/select2/4.1.0-rc.0/js/select2.min.js"
    "jquery.dataTables.min.js" = "https://cdn.jsdelivr.net/npm/datatables.net@1.11.5/js/jquery.dataTables.min.js"
    "dataTables.bootstrap4.min.js" = "https://cdn.jsdelivr.net/npm/datatables.net-bs4@1.11.5/js/dataTables.bootstrap4.min.js"
    "chart.min.js" = "https://cdn.bootcdn.net/ajax/libs/Chart.js/3.7.0/chart.min.js"
    "daterangepicker.min.js" = "https://cdn.jsdelivr.net/npm/daterangepicker@3.1.0/daterangepicker.min.js"
}

# 下载字体文件
$fontFiles = @{
    "fa-solid-900.woff2" = "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/webfonts/fa-solid-900.woff2"
    "fa-regular-400.woff2" = "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/webfonts/fa-regular-400.woff2"
    "fa-brands-400.woff2" = "https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free@5.15.4/webfonts/fa-brands-400.woff2"
}

# 下载图片文件
$imgFiles = @{
    "AdminLTELogo.png" = "https://cdn.bootcdn.net/ajax/libs/admin-lte/3.2.0/img/AdminLTELogo.png"
}

# 下载CSS文件
foreach ($file in $cssFiles.GetEnumerator()) {
    Write-Host "Downloading CSS: $($file.Key)"
    try {
        Invoke-WebRequest -Uri $file.Value -OutFile "$cssPath\$($file.Key)"
        Write-Host "Successfully downloaded $($file.Key)"
    } catch {
        Write-Host "Failed to download $($file.Key): $_"
    }
}

# 下载JS文件
foreach ($file in $jsFiles.GetEnumerator()) {
    Write-Host "Downloading JS: $($file.Key)"
    try {
        Invoke-WebRequest -Uri $file.Value -OutFile "$jsPath\$($file.Key)"
        Write-Host "Successfully downloaded $($file.Key)"
    } catch {
        Write-Host "Failed to download $($file.Key): $_"
    }
}

# 下载字体文件
foreach ($file in $fontFiles.GetEnumerator()) {
    Write-Host "Downloading Font: $($file.Key)"
    try {
        Invoke-WebRequest -Uri $file.Value -OutFile "$fontsPath\$($file.Key)"
        Write-Host "Successfully downloaded $($file.Key)"
    } catch {
        Write-Host "Failed to download $($file.Key): $_"
    }
}

# 下载图片文件
foreach ($file in $imgFiles.GetEnumerator()) {
    Write-Host "Downloading Image: $($file.Key)"
    try {
        Invoke-WebRequest -Uri $file.Value -OutFile "$imgPath\$($file.Key)"
        Write-Host "Successfully downloaded $($file.Key)"
    } catch {
        Write-Host "Failed to download $($file.Key): $_"
    }
}

Write-Host "All files downloaded successfully!" 